package com.hq.modeapp.bean;

import java.io.Serializable;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.tgb.lk.ahibernate.annotation.Column;
import com.tgb.lk.ahibernate.annotation.Id;
import com.tgb.lk.ahibernate.annotation.Table;
import com.tgb.lk.demo.annotation.PrimaryKey;

@Table(name = "News_Bean")
public class News_Bean implements Serializable{
	
	@Id
	@Column(name = "id")
	private int id; // ���,int����,��ݿ⽨��ʱ���ֶλ���Ϊ����
	
	@PrimaryKey
	@Column(name = "News_Bean_id", type = "INTEGER")
	private int News_Bean_id=-1; // ����һ������ֵ,��type = "INTEGER"�淶һ�°�.
	
	@Column(name = "title",type = "STRING")
	private String title;//标题
	@Column(name = "replyCount",type = "STRING")
	private String replyCount;//跟帖数
	@Column(name = "digest",type = "STRING")
	private String digest;//文摘
	@Column(name = "imgsrc",type = "STRING")
	private String imgsrc;//图片url
	@Column(name = "url",type = "STRING")
	private String url;//网页url
	
	
	
	public String getTitle() {
		return title;
	}



	public void setTitle(String title) {
		this.title = title;
	}



	public String getReplyCount() {
		return replyCount;
	}



	public void setReplyCount(String replyCount) {
		this.replyCount = replyCount;
	}



	public String getDigest() {
		return digest;
	}



	public void setDigest(String digest) {
		this.digest = digest;
	}



	public String getImgsrc() {
		return imgsrc;
	}



	public void setImgsrc(String imgsrc) {
		this.imgsrc = imgsrc;
	}



	public static ArrayList<News_Bean> parseJson(String str) {
		ArrayList<News_Bean> list = new ArrayList<News_Bean>();
		try {
			JSONObject jsonObject = new JSONObject(str);
			JSONArray jsonArray;
			jsonArray = jsonObject.getJSONArray("T1347415223240");
			int n = jsonArray.length();
			for (int i = 0; i < n; i++) {
				News_Bean bean = new News_Bean();
				bean.setTitle(jsonArray.getJSONObject(i).getString("title"));
				bean.setImgsrc(jsonArray.getJSONObject(i).getString("imgsrc"));
				bean.setDigest(jsonArray.getJSONObject(i).getString("digest"));
				bean.setReplyCount(jsonArray.getJSONObject(i).getString("replyCount"));
				bean.setUrl(jsonArray.getJSONObject(i).getString("url"));
				list.add(bean);
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;

	}



	public String getUrl() {
		return url;
	}



	public void setUrl(String url) {
		this.url = url;
	}
}
